<template>
  <div>
    <el-button type="primary" plain @click="add()">添加</el-button>
    <v-list @edit="edit"></v-list>
    <v-add :obj="obj" ref="aa"></v-add>
  </div>
</template>
<script>
import vAdd from "./components/add.vue";
import vList from "./components/list.vue";
import { mapGetters, mapActions } from "vuex";
export default {
  props: [],
  components: {
    vAdd,
    vList,
  },
  data() {
    return {
      obj: {
        //用来标识add.vue显示与隐藏
        isTrue: false,
        //用来表示点的是添加还是编辑
        isAdd: false,
      },
    };
  },
  computed: {
    ...mapGetters({}),
  },
  methods: {
    ...mapActions({}),
    //点击添加
    add() {
      //让add.vue显示
      this.obj.isTrue = true;
      //说明点的是添加
      this.obj.isAdd = true;
    },
    //list组件触发了edit
    edit(uid) {
      //让add.vue显示
      this.obj.isTrue = true;
      //说明点的是编辑
      this.obj.isAdd = false;
      //通过ref的方式执行add组件中的getOne方法
      this.$refs.aa.getOne(uid);
    },
  },
  mounted() {},
};
</script>
<style scoped>
</style>